package com.toogu.mazhangmen.util;

import android.content.Context;
import android.content.SharedPreferences;
import com.toogu.mazhangmen.MyApplication;

public class TokenUtil {

    private  Context context= MyApplication.getContext();
    private String token_type;
    private int expires_in;
    private String access_token;
    private String refresh_token;
    private String account;
    private String passWord;

    private String id;
    private String username;
    private String avatar_url;
    private String name;
    private String mobile;
    private String email;
    private String project_ids;
    private String status; //1启用，0禁用



    public  void setToken(){
        SharedPreferences.Editor editor = context.getSharedPreferences("token", context.MODE_PRIVATE).edit();
        editor.putString("token_type",token_type);
        editor.putInt("expires_in",expires_in);
        editor.putString("access_token",access_token);
        editor.putString("refresh_token",refresh_token);
        editor.apply();
    }

    public void setUserBean(String account,String passWord){
        SharedPreferences.Editor editor = context.getSharedPreferences("token", context.MODE_PRIVATE).edit();
        editor.putString("account",account);
        editor.putString("passWord",passWord);
        editor.putString("id",id);
        editor.putString("username",username);
        editor.putString("avatar_url",avatar_url);
        editor.putString("name",name);
        editor.putString("mobile",mobile);
        editor.putString("email",email);
        editor.putString("project_ids",project_ids);
        editor.putString("status",status);
        editor.apply();
    }

    public  void setClear(){
        SharedPreferences.Editor editor = context.getSharedPreferences("token", context.MODE_PRIVATE).edit();
        editor.putString("account","");
        editor.putString("passWord","");
        editor.putString("id","");
        editor.apply();
    }

    public String getToken_type() {
        SharedPreferences sprfMain= context.getSharedPreferences("token",context.MODE_PRIVATE);
        token_type=sprfMain.getString("token_type","");
        return token_type;
    }

    public double getExpires_in() {
        SharedPreferences sprfMain= context.getSharedPreferences("token",context.MODE_PRIVATE);
        expires_in=sprfMain.getInt("expires_in",0);
        return expires_in;
    }

    public String getAccess_token() {
        SharedPreferences sprfMain= context.getSharedPreferences("token",context.MODE_PRIVATE);
        access_token=sprfMain.getString("access_token","");
        return access_token;
    }

    public String getRefresh_token() {
        SharedPreferences sprfMain= context.getSharedPreferences("token",context.MODE_PRIVATE);
        refresh_token=sprfMain.getString("refresh_token","");
        return refresh_token;
    }

    public String getAccount() {
        SharedPreferences sprfMain= context.getSharedPreferences("token",context.MODE_PRIVATE);
        account=sprfMain.getString("account","");
        return account;
    }

    public String getPassWord(){
        SharedPreferences sprfMain= context.getSharedPreferences("token",context.MODE_PRIVATE);
        passWord=sprfMain.getString("passWord","");
        return passWord;
    }

    public String getId() {
        SharedPreferences sprfMain= context.getSharedPreferences("token",context.MODE_PRIVATE);
        id=sprfMain.getString("id","");
        return id;
    }

    public String getUsername() {
        SharedPreferences sprfMain= context.getSharedPreferences("token",context.MODE_PRIVATE);
        username=sprfMain.getString("username","");
        return username;
    }

    public String getAvatar_url() {
        SharedPreferences sprfMain= context.getSharedPreferences("token",context.MODE_PRIVATE);
        avatar_url=sprfMain.getString("avatar_url","");
        return avatar_url;
    }

    public String getName() {
        SharedPreferences sprfMain= context.getSharedPreferences("token",context.MODE_PRIVATE);
        name=sprfMain.getString("name","");
        return name;
    }

    public String getMobile() {
        SharedPreferences sprfMain= context.getSharedPreferences("token",context.MODE_PRIVATE);
        mobile=sprfMain.getString("mobile","");
        return mobile;
    }

    public String getEmail() {
        SharedPreferences sprfMain= context.getSharedPreferences("token",context.MODE_PRIVATE);
        email=sprfMain.getString("email","");
        return email;
    }

    public String getProject_ids() {
        SharedPreferences sprfMain= context.getSharedPreferences("token",context.MODE_PRIVATE);
        project_ids=sprfMain.getString("project_ids","");
        return project_ids;
    }

    public String getStatus() {
        SharedPreferences sprfMain= context.getSharedPreferences("token",context.MODE_PRIVATE);
        status=sprfMain.getString("status","");
        return status;
    }

}
